package pro.shushi.pamirs.hr.api.model.org;

import pro.shushi.pamirs.boot.base.ux.annotation.field.UxWidget;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxDetail;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxForm;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxTable;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxTableSearch;
import pro.shushi.pamirs.business.api.enumeration.StaffSizeEnum;
import pro.shushi.pamirs.meta.annotation.Field;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.base.IdModel;
import pro.shushi.pamirs.resource.api.enmu.CompanyNatureEnum;

import java.util.List;

// 模型中UX开头的注解(UxForm/UxTable/UxDetail等)可以不用写，都可在设计器中进行可视化配置; 代码里面写这些注解是为了默认页面的交互
@UxForm(grid = 3)
@UxDetail(grid = 3)
@Model.model(Corporation.MODEL_MODEL)
@Model(displayName = "示例HR-公司", labelFields = "shortName")
// 模型编码，参考：https://doc.oinone.top/oio4/9236.html
@Model.Code(sequence = "SEQ", prefix = "C", size = 5, step = 1, initial = 10000)
public class Corporation extends IdModel {

    public static final String MODEL_MODEL = "hr.simple.Corporation";

    @UxTableSearch.FieldWidget(@UxWidget())
    @UxForm.FieldWidget(@UxWidget(readonly = "true", hint = "为空时自动生成"))
    @Field.String
    @Field(displayName = "编码", unique = true)
    private String code;

    @UxTableSearch.FieldWidget(@UxWidget())
    @Field.String
    @Field(displayName = "简称", required = true)
    private String shortName;

    @Field.String
    @Field(displayName = "全称")
    private String fullName;

    @Field.many2one
    @Field.Relation(relationFields = {"parentCode"}, referenceFields = {"code"})
    @Field(displayName = "上级公司", summary = "上级公司")
    private Corporation parent;

    @Field.String
    @Field(displayName = "上级公司编码", summary = "上级公司编码", invisible = true)
    private String parentCode;

    @Field.String
    @Field(displayName = "法人", required = true)
    private String legalPerson;

    @Field.Enum
    @Field(displayName = "公司性质（组织性质）", required = true)
    private CompanyNatureEnum companyNature;

    @Field.Enum
    @Field(displayName = "人员规模", required = true)
    private StaffSizeEnum staffSize;

    @Field.String
    @Field(displayName = "官网")
    private String website;

    @Field.String
    @Field(displayName = "营业执照号")
    private String licenseNo;

    @Field.String
    @Field(displayName = "组织机构代码")
    private String organizationNo;

    @Field.String
    @UxForm.FieldWidget(@UxWidget(span = 2))
    @UxDetail.FieldWidget(@UxWidget(span = 2))
    @Field(displayName = "办公地")
    private String officeAddress;

    // 模型中UX开头的注解(UxForm/UxTable/UxDetail等)可以不用写，都可在设计器中进行可视化配置; 代码里面写这些注解是为了默认页面的交互
    @UxForm.FieldWidget(@UxWidget(widget = "UploadImg"))
    @UxTable.FieldWidget(@UxWidget(widget = "UploadImg"))
    @UxDetail.FieldWidget(@UxWidget(widget = "UploadImg"))
    @Field.String(size = 256)
    @Field(displayName = "公司logo")
    private String logo;

    // 模型中UX开头的注解(UxForm/UxTable/UxDetail等)可以不用写，都可在设计器中进行可视化配置; 代码里面写这些注解是为了默认页面的交互
    // 字段之序列化：https://doc.oinone.top/oio4/9238.html
    // columnDefinition 数据库字段类型，如果需要自定义不在ttype对应数据库字段类型列表中的类型请使用此字段填写完整数据库字段定义
    @UxForm.FieldWidget(@UxWidget(widget = "UploadImg"))
    @UxTable.FieldWidget(@UxWidget(widget = "UploadImg"))
    @UxDetail.FieldWidget(@UxWidget(widget = "UploadImg"))
    @Field.Advanced(columnDefinition = "varchar(4096)")
    @Field(displayName = "公司宣传图", multi = true, serialize = Field.serialize.COMMA)
    private List<String> images;

    @Field.Html
    @Field.Advanced(columnDefinition = "TEXT")
    @Field(displayName = "公司简介")
    private String remark;
}
